package org.teach.study.boot.controller;

import org.quincy.rock.core.vo.PageSet;
import org.quincy.rock.core.vo.Result;
import org.quincy.rock.core.vo.Sort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.teach.study.boot.Entity;
import org.teach.study.boot.SimpleController;
import org.teach.study.boot.entity.Love;
import org.teach.study.boot.service.LoveService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * <b>LoveController。</b>
 * <p><b>详细说明：</b></p>
 * <!-- 在此添加详细说明 -->
 * 无。
 * @version 1.0
 * @author mex2000
 * @since 1.0
 */
@Slf4j
@Api(tags = "爱好管理模块")
@Controller
@RequestMapping("/love")
public class LoveController extends SimpleController<Love, LoveService> {

	@ApiOperation(value = "条件分页查询", notes = "")
	@ApiImplicitParams({ @ApiImplicitParam(name = "searchCode", value = "代码(支持like)，允许null"),
			@ApiImplicitParam(name = "searchName", value = "名称(支持like)，允许null"),
			@ApiImplicitParam(name = "sort", value = "排序规则字符串"),
			@ApiImplicitParam(name = "pageNumber", value = "页码", required = true, dataType = "int"),
			@ApiImplicitParam(name = "pageSize", value = "页大小", required = true, dataType = "int") })
	@RequestMapping(value = "/queryPageByCondition", method = { RequestMethod.GET })
	public @ResponseBody Result<PageSet<? extends Entity>> queryPageByCondition(String searchCode, String searchName,
			String sort, @RequestParam("pageNumber") int page, @RequestParam int pageSize) {
		log.debug("call queryPageByCondition");
		PageSet<? extends Entity> ps = this.getService().queryPageByCondition(searchCode, searchName, Sort.parse(sort),
				page, pageSize);
		return Result.toResult(ps);
	}
}
